Use case: HAL GPIO initialization

Sequence diagram

HAL GPIO initialization (HAL1)

@startuml
title: HAL GPIO initialization (HAL1)

hide footbox
participant "User Application" as App
participant "GPIO" as GPIO

App -> App : Fill GPIO_InitTypeDef\nPin/Mode/Pull/Speed
App -> GPIO : HAL_GPIO_Init(GPIOx, &GPIO_InitStructure)

@enduml

Code snippet

HAL1

HAL2

GPIO_Init_TypeDef GPIO_InitStructure;

GPIO_InitStructure.Pin  = GPIO_PIN_5;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOx, &GPIO_InitStructure);
hal_gpio_config_t GPIO_ConfigStructure;

GPIO_ConfigStructure.mode        = HAL_GPIO_MODE_OUTPUT;
GPIO_ConfigStructure.output_type = HAL_GPIO_OUTPUT_PUSHPULL;
GPIO_ConfigStructure.pull        = HAL_GPIO_PULL_NO;

HAL_GPIO_Init(HAL_GPIOx, HAL_GPIO_PIN_5, &GPIO_ConfigStructure);

Key changes

  1. HAL2 passes the pin as a separate argument (not only via a struct field).

  2. HAL2 separates output configuration (mode vs output type) explicitly.

  3. Naming and enum values differ between HAL1 and HAL2 for pull/mode/output type.